/*
 * cudanDeviceMemory.h
 *
 *  Created on: Dec 8, 2009
 *      Author: daniel
 */

#ifndef CUDANDEVICEMEMORY_H_
#define CUDANDEVICEMEMORY_H_

#include "cudanBaseMemory.h"

namespace CUDAN
{
	// Defines an abstract type for memory on the device.
	template<typename T, int D>
	class DeviceMemory : public BaseMemory<T,D>
	{
	public:
		// Stores the dimension size on the device in global.
		int* sizeDimGPU;

	public:
		DeviceMemory();
		virtual ~DeviceMemory() {};

	public:
		using BaseMemory<T,D>::getIndex;
		virtual __device__ int getIndex(int[D]);
		virtual __device__ int getIndex(int[D],int[D]);
		virtual void freeMemory() = 0;
		virtual void print() = 0;
		virtual void print(DimensionSizeVector&) = 0;
		virtual bool setSize(DimensionSizeVector&);
		virtual bool allocateMemory(DimensionSizeVector&) = 0;
		virtual bool copyFrom(HostMemory<T,D>*) = 0;
		virtual bool copyFrom(DeviceMemory<T,D>*) = 0;
		virtual bool copyTo(HostMemory<T,D>*) = 0;
		virtual bool copyTo(DeviceMemory<T,D>*) = 0;
	};
}

#include "cudanDeviceMemory.cpp"

#endif /* CUDAFWDEVICEMEMORY_H_ */
